import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { Language } from "../../../../extend/language/Language";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { ObjCreate } from "../common/ObjCreate";
import { TitleItem } from "../common/item/TitleItem";
import { ObjTeamCreate } from "../common/ObjTeamCreate";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { TilePanel } from "../equipment/TilePanel";
import { ArenaCrossMyMatchCellRenderer } from "./cellRenderer/ArenaCrossMyMatchCellRenderer";
import { SArenaCrossBattleRecords } from "../../../../Message/Public/SArenaCrossBattleRecords";
import { ArenaCrossbattleRecordData } from "./arenaCrossData/ArenaCrossbattleRecordData";
import { SArenaCrossBattleRecord } from "../../../../Message/Public/SArenaCrossBattleRecord";
import { DataProvider } from "../../../../fl/data/DataProvider";
//class ArenaCrossMyBattlesWindow
    
    export  class ArenaCrossMyBattlesWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(540, 416);
            titleHeight = 26;
            title = Language.getString(44219);
            this.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.onAddToStage);
            return;
        }

        protected onAddToStage(arg1: Object /* flash.events.Event */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.ArenaCrossGetMyBattleRecords));
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createSpBannerAndBg(18, 39, 504, 364, "", this);
            var loc1=new Vector.<TitleItem>();
            loc1.push(new TitleItem(Language.getString(44236), 50));
            loc1.push(new TitleItem(Language.getString(44237), 110));
            loc1.push(new TitleItem(Language.getString(44238), 60));
            loc1.push(new TitleItem(Language.getString(44237), 185));
            loc1.push(new TitleItem(Language.getString(44239), 70));
            var loc2=ObjTeamCreate.createTitles(loc1);
            ObjCreate.setObjAttri(loc2, 20, 48, -1, -1, this);
            this._tfNoRecord = ObjCreate.createTextField(Language.getString(44240), 244, 208, 200, 20, this, GlobalStyle.textFormat6);
            this._tfNoRecord.visible = true;
            this._arenaTopListPanel = new TilePanel();
            this._arenaTopListPanel.setSize(498, 335);
            this._arenaTopListPanel.rowHeight = 67;
            this._arenaTopListPanel.columnWidth = 480;
            this._arenaTopListPanel.setStyle("cellRenderer", ArenaCrossMyMatchCellRenderer);
            this._arenaTopListPanel.x = 23;
            this._arenaTopListPanel.y = 65;
            this.addChild(this._arenaTopListPanel);
            this._arenaTopListPanel.visible = false;
            return;
        }

        public updateBattles(arg1: SArenaCrossBattleRecords): void
        {
            var loc2=null;
            var loc1=new Array<any>();
            var loc3=0;
            while (loc3 < arg1.records.length) 
            {
                loc2 = new ArenaCrossbattleRecordData();
                loc2.index = loc3 + 1;
                loc2.arenaCrossBattleRecord = arg1.records[loc3] as SArenaCrossBattleRecord;
                loc1.push(loc2);
                ++loc3;
            }
            this._arenaTopListPanel.dataProvider = new DataProvider(loc1);
            var loc4=loc1.length > 0;
            this._arenaTopListPanel.visible = loc4;
            this._tfNoRecord.visible = !loc4;
            return;
        }

        public static get instance(): ArenaCrossMyBattlesWindow
        {
            if (!ArenaCrossMyBattlesWindow._instance) 
            {
                ArenaCrossMyBattlesWindow._instance = new ArenaCrossMyBattlesWindow();
            }
            return ArenaCrossMyBattlesWindow._instance;
        }

        /* internal */ /* var */_tfNoRecord: Object /* flash.text.TextField */;

        /* internal */ /* var */_arenaTopListPanel: TilePanel;

        /* internal */ static /* var */_instance: ArenaCrossMyBattlesWindow;
    }
